
# para o wizard
from django.contrib.formtools.wizard import FormWizard
from django.template.context import RequestContext
from django import forms
    
class Passo1(forms.Form):
    id = forms.IntegerField(required=False,widget=HiddenInput())
    username = forms.IntegerField(required=False,  widget=HiddenInput())
    tipo = forms.ChoiceField(choices=Tipo_Choices)

class Passo2(forms.Form):
        nome = models.CharField(max_length=50, blank=True)
        banco = models.ForeignKey(Banco) 
    

class ContaWizard(FormWizard):
        # Dictionary of extra template context variables.
    extra_context = {}

    # The HTML (and POST data) field name for the "step" variable.
    step_field_name="wizard_step"
    next_step_field_name="wizard_next_step"
    max_step_field_name="wizard_max_step"
    wizard_data_name="ContaWizard"
    
    def done(self, request, form_list):
        form = {}
        for form in form_list:
            for field, value in form.cleaned_data.iteritems():
                form[field] = value
        return render_to_response('conta.html', locals())

    def get_template(self, step):
        return 'conta_wizard.html'

    def render_template(self, request, form, previous_fields, step, max_step, context=None):
        context = context or {}
        context.update({self.wizard_data_name:request.POST})
        context.update(self.extra_context)
        return render_to_response(self.get_template(step), dict(context,
            next_step_field=self.next_step_field_name,
            max_step_field=self.max_step_field_name,
            max_step=max_step,
            step_field=self.step_field_name,
            step0=step,
            step=step + 1,
            step_count=self.num_steps(),
            form=form,
            previous_fields=previous_fields
        ), context_instance=RequestContext(request))     
